package com.fei.controller;

import com.fei.bean.CommentBean;
import com.fei.bean.FileVideoBean;
import com.fei.bean.UserBean;
import com.fei.bean.VideoBean;
import com.fei.service.CommentService;
import com.fei.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class VideoController {
    
    @Autowired
    VideoService videoService;
    @Autowired
    CommentService commentService;

    @RequestMapping("/user/ajax/video")
    public String video(Model model){
        List<VideoBean> videoBeanThree = videoService.selectVideoThreeService();
        List<VideoBean> videoBeanList = videoService.excludeThreeFindAllService();
        model.addAttribute("videoBeanThree",videoBeanThree);
        model.addAttribute("videoBeanList",videoBeanList);
        return "video::video";
    }

    @RequestMapping("/user/ajax/videoDetail")
    public String videoDetail(Integer id,Model model){
        VideoBean videoBean = videoService.selectOneIdVideoAndCommentService(id);
        List<VideoBean> videoBeanList = videoService.excludeSelectOneIdVideoFiveService(id);
        Integer countComment = commentService.selectOneIdCountService(id);
//        用于jplayer视频
        FileVideoBean fileVideo = new FileVideoBean();
        fileVideo.setTitle(videoBean.getVideo_name());
        fileVideo.setM4v(videoBean.getVideo_path());
        fileVideo.setPoster(videoBean.getImg());
        model.addAttribute("MvMusic",fileVideo);
        model.addAttribute("countComment",countComment);
        model.addAttribute("videoBean",videoBean);
        model.addAttribute("videoBeanList",videoBeanList);
        return "video-detail::videoDatail";
    }



}
